local que_luange = fk.CreateSkill {
    name = "que_luange",
}

Fk:loadTranslationTable {
    ["que_luange"] = "鸾歌",
    [":que_luange"] = "每种牌名限一次，当有锦囊牌进入弃牌堆时，你可以失去任意点体力选择等量张获得；当你使用〖鸾歌〗获得过的锦囊牌时，你回复一点体力。",

    ["#que_luangeex-invoke"] = "鸾歌：%arg进入弃牌堆，是否失去一点体力获得之？",
    ["#que_luange-invoke"] = "鸾歌：有锦囊牌进入弃牌堆，是否失去体力并从中选择获得？",
    ["#que_luange-asktocard"] = "鸾歌：请选择你要获得的牌",

    ["@$que_luange_cards"] = "鸾歌",
}
que_luange:addEffect(fk.AfterCardsMove, {
    anim_type = "drawcard",
    can_trigger = function(self, event, target, player, data)
        local mark = player:getTableMark("@$que_luange_cards")
        if player:hasSkill(que_luange.name) then
            local cards = {}
            for _, move in ipairs(data) do
                if move.toArea == Card.DiscardPile then
                    for _, info in ipairs(move.moveInfo) do
                        if not table.contains(mark, Fk:getCardById(info.cardId).trueName) and Fk:getCardById(info.cardId):getMark("que_qingkong-turn") == 0
                            and Fk:getCardById(info.cardId, true).type == Card.TypeTrick
                            and table.contains(player.room.discard_pile, info.cardId) then
                            table.insertIfNeed(cards, info.cardId)
                        end
                    end
                end
            end
            cards = player.room.logic:moveCardsHoldingAreaCheck(cards) --此处需要判定此牌是否再次被移动过
            if #cards > 0 then
                event:setCostData(self, { cards = cards })
                return true
            end
        end
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local cards = table.simpleClone(event:getCostData(self).cards)
        local prompt = "#que_luange-invoke"
        if #cards == 1 then
            prompt = "#que_luangeex-invoke:::" .. Fk:getCardById(cards[1]):toLogString()
        end
        return room:askToSkillInvoke(player, { skill_name = que_luange.name, prompt = prompt })
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local mark = player:getTableMark("@$que_luange_cards")
        local card = table.filter(event:getCostData(self).cards, function(c)
            return table.contains(room.discard_pile, c)
        end)
        if #card == 0 then
            return
        elseif #card > 1 then
            card = room:askToChooseCards(player, {
                target = player,
                min = 1,
                max = #card,
                flag = { card_data = { { que_luange.name, card } } },
                skill_name = que_luange.name,
                prompt = "#que_luange-asktocard",
            })
        end
        room:loseHp(player, #card, que_luange.name)
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonJustMove, que_luange.name, nil, true, player)
        for _, i in ipairs(card) do
            room:addTableMarkIfNeed(player, "@$que_luange_cards", Fk:getCardById(i).trueName) --若存在多个相同的值，可以用此函数添加
        end
        room:addPlayerMark(player, "qingkog_cishu")
        if player:getMark("qingkog_cishu") > 2 then
            room:addPlayerMark(player, "que_qingkong")
            room:setPlayerMark(player, "qingkog_cishu", 0)
        end
    end,
})

que_luange:addEffect(fk.CardUsing, {
    anim_type = "support",
    can_trigger = function(self, event, target, player, data)
        local mark = player:getTableMark("@$que_luange_cards")
        return target == player and player:hasSkill(que_luange.name) and data.card.type == Card.TypeTrick and
            player:isWounded() and table.contains(mark, data.card.trueName)
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:recover {
            who = player,
            num = 1,
            recoverBy = player,
            skillName = que_luange.name,
        }
    end,
})
return que_luange
